package com.example.spindrift.Controllers;

import com.example.spindrift.dao.SysSingMapper;
import com.example.spindrift.models.SysSing;
import com.example.spindrift.service.SingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/Sing")
public class SingController {
    @Autowired
    SingService singService;

    /**
     * 获取所有歌手信息
     * @return
     */
    @GetMapping("/getAllSing")
    public List<SysSing> getAllSing() {
        return singService.getAllSing();
    }

    /**
     * 根据歌手ID获取歌手信息
     * @param singId 歌手ID
     * @return
     */
    @GetMapping("/getSingById")
    public SysSing getSingById(@RequestParam Integer singId) {
        return singService.getSingById(singId);
    }

    /**
     * 根据歌手名称进行模糊查询
     * @param keyword 歌曲关键字
     * @return
     */
    @GetMapping("/searchSing")
    public List<SysSing> searchSing(@RequestParam String keyword) {
        return singService.searchSing(keyword);
    }

    /**
     * 根据歌手名称获取歌手信息
     * @param singName 歌手名称
     * @return
     */
    @GetMapping("/getSingByUserName")
    public List<SysSing> getSingByUserName(@RequestParam String singName) {
        return singService.getSingByUserName(singName);
    }

    /**
     * 添加一条歌手信息
     * @param sing 歌手信息
     * @return
     */
    @PostMapping("/insertSing")
    public Integer insertSing(@RequestBody SysSing sing) {
        return singService.insertSing(sing);
    }

    /**
     * 更新一条歌手信息
     * @param sing 歌手信息
     * @return
     */
    @PostMapping("/updateSing")
    public Boolean updateSing(@RequestBody SysSing sing) {
        return singService.updateSing(sing) > 0;
    }

    /**
     * 根据歌手ID删除一条歌手信息
     * @param singId 歌手ID
     * @return
     */
    @GetMapping("/deleteSing")
    public Boolean deleteSing(@RequestParam Integer singId) {
        return singService.deleteSing(singId) > 0;
    }
}
